#include "test_adc.h"
#include "cm_uart.h"
#include "cm_demo_uart.h"
/* 
   指令格式：
   CM：ADC_OPERATION：OPEN:#1    #1:通道序号
   CM：ADC_OPERATION：READ:#1
   CM：ADC_OPERATION：CLOSE:#1

*/


void cm_test_adc_operation(unsigned char*cmd[],int len)
{
    if(0 == strncmp("OPEN",cmd[2],strlen("OPEN")))
    {
        //cm_adc_dev_e dev = atoi(cmd[3]);
        //cm_demo_printf("cm_adc_open ret:%d\n", cm_adc_open(dev));
    }else if(0 == strncmp("CLOSE",cmd[2],strlen("CLOSE")))
    {
        // cm_adc_dev_e dev = atoi(cmd[3]);
        // cm_adc_close(dev);
        // cm_demo_printf("cm_adc_close no return\n");
    }else if(0 == strncmp("READ",cmd[2],strlen("READ")))
    {
        cm_adc_dev_e dev = atoi(cmd[3]);
        int32_t voltage = 0;
        int32_t ret = cm_adc_read(dev, &voltage);
        cm_demo_printf("cm_adc_read ret:%d\n",ret);
        OCTEST_FUNC_EXPECT_FALSE(ret, cm_adc_read);
        cm_demo_printf("voltage:%d\n",voltage);
    }
    // else if(0 == strncmp("VBAT",cmd[2],strlen("VBAT")))
    // {
    //     int32_t voltage = 0;
    //     cm_demo_printf("cm_adc_vbat_read ret:%d\n",cm_adc_vbat_read(&voltage));
    //     cm_demo_printf("voltage:%d\n",voltage);
    // }
    else{
        cm_demo_printf("param error!\n");
    }
}
